home *** CD-ROM | disk | FTP | other *** search
/ APDL Eductation Resources / APDL Eductation Resources.iso / programs / database / powerbase / docs / QBE < prev    next >
Encoding:
Text File  |  1997-08-02  |  5.9 KB  |  109 lines

  1.                    APPENDIX C − QUERY-BY-EXAMPLE
  2.                    =============================
  3. In all versions of Powerbase prior to v. 6.99 producing reports (lists) of
  4. selected records requires you to enter a search formula. (See Ch.3 for full
  5. details).  We will call this the SF method. In v. 6.99 it is possible, for
  6. the first time, to use an alternative query method called query-by-example
  7. (QBE for short).
  8.  
  9. What is QBE?
  10. ============
  11. The user is presented with a blank record and invited to type into the
  12. relevant fields the data which must be matched in order for the record to be
  13. included in the report (list). What you are saying, in effect, is “I want a
  14. list of all records which look like this. I don’t care what’s in any of the
  15. fields I haven’t filled in, but the ones I have filled in must correspond to
  16. what I have typed.”  e.g. in the !Elements database if you wanted to print a
  17. list of all transition metals you would simply enter T in the Group field
  18. and then proceed with the list.  The tag of the field isn't needed at all,
  19. whereas using a search formula requires you to type GP=T.
  20.  
  21. How to use QBE
  22. ==============
  23. Choose Print or Print=>Match from the menu (or type the Print key on the
  24. keyboard). The Match window is displayed and, if you have used an earlier
  25. version of Powerbase, you will see that its layout has been changed
  26. somewhat.  One of the option switches at the left-hand side is labelled
  27. Query by example. Click on this with SELECT and the record window will
  28. display a blank record with the message “Query-by-example”: Enter required
  29. values in relevant fields in the window title. Enter the data to be matched
  30. then  either click with SELECT on the Print button of the Match window or
  31. else press the Print key again.
  32.  
  33. If you simply enter the required target strings Powerbase assumes that you
  34. want the relevant fields to match exactly, i.e the effect is the same as
  35. using “=” in a search formula. There are, however, other  comparators
  36. besides “=” which may be used in search formulae. (see 3.3.3, pp.13-14 for
  37. explanation and complete list). You may use any of these in a QBE query by
  38. placing them at the start of the string, e.g. {Avenue in an Address field
  39. would match all records where the field contained the word “Avenue”.  An
  40. address such as “15 Acacia Avenue” could be found by this method whereas
  41. just entering the word “Avenue” wouldn’t work because it would require the
  42. field to read “Avenue” and nothing more. 
  43.  
  44. Wildcards may be used; e.g. you could print from the !Elements database all
  45. elements ending in IUM by entering $IUM in the NAME field or all those whose
  46. symbol began with H by entering H# in the SYM field.
  47.  
  48. You may also specify a target list (as described on p. 14) to make the
  49. search include all records matching any item in the list. e.g.
  50. Leeds,Liverpool,Manchester in a Town field would cause records with any of
  51. these places to be included. 
  52.  
  53. On p.13 there is also a description of tag lists which let you instruct
  54. Powerbase to include records in which only one of a number of fields need
  55. match the target string. You can do this with QBE provided that the fields
  56. form a contiguous group. The target string (which may be a target list, be
  57. wild-carded or be preceded by a comparator) is entered in the first field of
  58. the group. Press Return and enter " (double quote or "ditto" mark) in the
  59. next field and for the remaining fields of the group. (Pressing Return
  60. rather than moving the caret by means of the mouse ensures that you really
  61. are dealing with a contiguous group of fields.)
  62.  
  63. QBE vs SF
  64. =========
  65. So what are the advantages and disadvantages?  QBE is very intuitive and
  66. avoids the need to bother with field tags or the minutiae of search formula
  67. syntax.  On the other hand SF is more flexible and comprehensive: there are
  68. some things you simply cannot do with QBE.  Some of the limitations have
  69. already been mentioned but here is a complete list. 
  70.  
  71. •       Except where exact matches (“field=target string”) are required it might
  72.         not be possible to fit the target string or list into the relevant
  73.         field.  One consequence is that you can't target a Date field for
  74.         all dates prior to, say, 01-06-90 since dates fit their fields
  75.         exactly leaving no room for the necessary < comparator.  Such a
  76.         search is perfectly possible with SF.
  77.  
  78. •       Searches involving multiple fields and the same target, i.e. those where
  79.         FieldX or FieldY or FieldZ must match are only possible where the
  80.         fields form a contiguous sequence. With SF it is possible to perform
  81.         such searches on fields dotted about the record.
  82.  
  83. •       There is no equivalent in QBE to the @= (any field in the record matches)
  84.         or @{ (any field contains) searches which are possible with SF
  85.  
  86. •       You can't search for text in an external text field, i.e. fields of Text
  87.         or Text block type. You can with SF.
  88.  
  89. •       You can't include Check-box fields in QBE searches.
  90.  
  91. •       Since QBE doesn't use tags you can’t force a comparison-by-numeric-value
  92.         on a non-numeric field (See 3.3.3, p. 15).
  93.  
  94. •       Calculated fields and those belonging to the Stamp class cannot be used by
  95.         QBE because you cannot type into them!
  96.  
  97. If your requirements involve only fairly simple searches then QBE might be
  98. just what you’ve been looking for, but if complex multiple searches are
  99. often needed then SF is the one to go for. It is, of course, a simple matter
  100. to switch between the two.
  101.  
  102. As supplied, Powerbase uses SF as the query method and the Query by example
  103. switch will be deselected when the Match window is displayed. If you want to
  104. make QBE the default you can edit the last line of the Config file so that
  105. the beginning reads QBE instead of SF. Selecting the Print function will
  106. then produce the blank record without displaying the Match window at all. 
  107. There is, of course, no Print button to click with the mouse after you have
  108. entered the target strings so you tell Powerbase proceed by pressing the
  109. Print key again.